ref(vcs): Improve find_base_sha debuggability#2806
Merged
szokeasaurusrex merged 1 commit intomasterfrom Sep 29, 2025
Merged
Conversation
Rather than emitting `debug!` logs (which we don't show in tests) within the `find_base_sha` and `extract_pr_base_sha_from_event` function, improve these methods by returning proper error types, which include the underlying error as a cause. The calling code is now responsible for debug-logging these errors, which is still desired, as we expect these functions to error when run outside of a GitHub Actions environment. But, now we will have more information available when debugging test failures, and the debug logs at runtime will also likely be more detailed.
runningcode
approved these changes
Sep 29, 2025
| .or_else(|| vcs::find_base_sha().ok().map(Cow::Owned)); | ||
| .or_else(|| { | ||
| vcs::find_base_sha() | ||
| .inspect_err(|e| debug!("Error finding base SHA: {}", e)) |
Contributor
There was a problem hiding this comment.
TIL inspect_err. nice!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rather than emitting
debug!logs (which we don't show in tests) within thefind_base_shaandextract_pr_base_sha_from_eventfunction, improve these methods by returning proper error types, which include the underlying error as a cause.The calling code is now responsible for debug-logging these errors, which is still desired, as we expect these functions to error when run outside of a GitHub Actions environment. But, now we will have more information available when debugging test failures, and the debug logs at runtime will also likely be more detailed.
Note
Refactors base SHA discovery to return Result<Option> with contextual errors and updates caller to debug-log failures.
src/utils/vcs.rs):find_base_shatoResult<Option<String>>; add contextual errors when reading/parsingGITHUB_EVENT_PATH.extract_pr_base_sha_from_eventreturnResult<Option<String>>with JSON parse context.Contextand propagate errors instead of silent debug logs.Optionon success paths and errors on malformed JSON/missing env.src/commands/build/upload.rs):Result<Option<...>>; addinspect_errdebug logging and flattenOption.Written by Cursor Bugbot for commit 1c17276. This will update automatically on new commits. Configure here.